// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Zone Block Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 18 : TYPE_ZONEBLOCK

// Function declarations
reserve function ZoneBlock_DebugDraw
reserve function ZoneBlock_DebugSpawn

// Static Values
public value ZoneBlock_value17 = 0;

// Tables

function ZoneBlock_DebugDraw
	temp4 = object[0].value10
	temp4 -= ZoneBlock_value17
	DrawSprite(temp4)
end function


function ZoneBlock_DebugSpawn
	temp4 = object[0].value10
	temp4 -= ZoneBlock_value17
	temp5 = 18
	CallFunction(DebugMode_SpawnObject)
	object[arrayPos0].drawOrder = 4
	object[arrayPos0].groupID = GROUP_BLOCKS
end function


event ObjectMain
	if object.state == 1
		object.frame = object.value0
		object.frame >>= 3
		object.value0++
		if object.value0 == 32
			object.value0 = 0
			object.state = 0
			object.frame = 0
		end if
	end if
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		CallFunction(SpecialSetup_Function10)
	next
end event


event ObjectDraw
	CallFunction(SpecialSetup_Function9)
	DrawSpriteXY(object.propertyValue, temp0, temp1)
end event


event ObjectStartup
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-12, -12, 24, 24, 326, 176)
	SpriteFrame(-12, -12, 24, 24, 351, 176)
	SpriteFrame(-12, -12, 24, 24, 376, 176)
	SpriteFrame(-12, -12, 24, 24, 426, 176)
	SpriteFrame(-12, -12, 24, 24, 451, 176)
	SpriteFrame(-12, -12, 24, 24, 476, 176)
	SpriteFrame(-12, -12, 24, 24, 476, 276)
	foreach (TypeName[Zone Block], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].groupID = GROUP_BLOCKS
	next
	temp0 = 0
	ZoneBlock_value17 = DebugMode_ObjCount
	while temp0 < 7
		SetTableValue(TypeName[Zone Block], DebugMode_ObjCount, DebugMode_TypeTable)
		SetTableValue(ZoneBlock_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
		SetTableValue(ZoneBlock_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
		DebugMode_ObjCount++
		temp0++
	loop
end event

event RSDKDraw
	DrawSpriteXY(object.propertyValue)
end event

event RSDKLoad
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-12, -12, 24, 24, 326, 176)
	SpriteFrame(-12, -12, 24, 24, 351, 176)
	SpriteFrame(-12, -12, 24, 24, 376, 176)
	SpriteFrame(-12, -12, 24, 24, 426, 176)
	SpriteFrame(-12, -12, 24, 24, 451, 176)
	SpriteFrame(-12, -12, 24, 24, 476, 176)
	SpriteFrame(-12, -12, 24, 24, 476, 276)
end event
